
<div class="titlebar"><i class="iconfont icon-xiugaidenglumima"></i>优惠券权限</div>  
<form id="form" action="{:url('coupon/edit',['page' => $page])}">
<input type="hidden" name="id" value="{$info.id}"/>
<input type="hidden" name="img" value="{$info.img}" id="picture" />
<table class="formtable"> 
   <tr><th>使用规则:</th><td>
        <label>每天:</label><input class="input w90" datatype="n" type="text" name="daynum" value="{$info.daynum}" /> 次 
        <label>间隔:</label><input class="input w90" datatype="n" type="text" name="longtime" value="{$info.longtime}" /> 分
        <label>生效:</label>
        <select class="select w110" datatype="*" name="ontypes" class="select">
            <option value="0" {if $info.ontypes == 0}selected{/if}>立即生效</option>
            <option value="1" {if $info.ontypes == 1}selected{/if}>隔天生效</option>
        </select>
     </td></tr>
    <tr><th>使用时间:</th><td>
        <input class="input ui-date w120" datatype="date" type="text" name="starttime" value="{if !empty($info.starttime)}{$info.starttime|date='Y-m-d'}{/if}" />
        至
        <input class="input ui-date w120" datatype="date" type="text" name="endtime" value="{if !empty($info.starttime)}{$info.endtime|date='Y-m-d'}{/if}" />
    </td></tr>
    <tr><th>周几可用:</th><td>
        <span class="badge bg-blue"><input type="checkbox" value="0" name="weekday[]"{if $info.weekday && in_array(0,$info.weekday)} checked{/if}> 星期日</span>
        <span class="badge bg-blue"><input type="checkbox" value="1" name="weekday[]"{if $info.weekday && in_array(1,$info.weekday)} checked{/if}> 星期一</span>
        <span class="badge bg-blue"><input type="checkbox" value="2" name="weekday[]"{if $info.weekday && in_array(2,$info.weekday)} checked{/if}> 星期二</span>
        <span class="badge bg-blue"><input type="checkbox" value="3" name="weekday[]"{if $info.weekday && in_array(3,$info.weekday)} checked{/if}> 星期三</span>
        <span class="badge bg-blue"><input type="checkbox" value="4" name="weekday[]"{if $info.weekday && in_array(4,$info.weekday)} checked{/if}> 星期四</span>
        <span class="badge bg-blue"><input type="checkbox" value="5" name="weekday[]"{if $info.weekday && in_array(5,$info.weekday)} checked{/if}> 星期五</span>
        <span class="badge bg-blue"><input type="checkbox" value="6" name="weekday[]"{if $info.weekday && in_array(6,$info.weekday)} checked{/if}> 星期六</span>
    </td></tr>
    <tr><th>优惠券价格:</th><td>
        <label>买单:</label><input class="input w110" datatype="npot" type="text" name="pay_price" value="{$info.pay_price}" />
        <label>购买:</label><input class="input w110" datatype="npot" type="text" name="shop_price" value="{$info.shop_price}" />           
    </td></tr>
</table>
<div class="titlebar"><i class="iconfont icon-text_icon"></i>优惠券信息</div>  
<table class="formtable">
    {if empty($info)}
    <th>商家:</th>
    <td>
        <input id="store_id" class="readonly input w100" type="text" name="store_id" value="0" />
        <button url="{:url('allwin/store/selectStore',['input' => 'uid'])}" type="button" class="selectid button"><i class="iconfont icon-my_icon"></i>选择店铺</button>
    </td>
    {/if}
    <tr><th>优惠券主题:</th><td>
        <select class="select w200" datatype="*" name="theme" class="select">
            <option value="blue" {if $info.theme == 'blue'}selected{/if}>石板蓝</option>
            <option value="red" {if $info.theme == 'red'}selected{/if}>永固红</option>
            <option value="green" {if $info.theme == 'green'}selected{/if}>青草绿</option>
            <option value="purple" {if $info.theme == 'green'}selected{/if}>青草绿</option>
            <option value="yellow" {if $info.theme == 'yellow'}selected{/if}>晨曦黄</option>
            <option value="gray" {if $info.theme == 'gray'}selected{/if}>石板灰</option>
        </select>
    </td></tr>
   <tr><th>优惠券类型:</th><td>
        <select id="types" class="select w200" datatype="*" name="types" class="select">
            <option value="0" {if $info.types == 0}selected{/if}>抵扣优惠券</option>
            <option value="1" {if $info.types == 1}selected{/if}>折扣优惠券</option>
        </select>
    </td></tr>
   <tr><th>优惠券名称:</th><td><input class="input w400" datatype="*" type="text" name="name" value="{$info.name}" /></td></tr>
   <tr><th>规则描述:</th><td><input class="input w300" datatype="*" type="text" name="tips" value="{$info.tips}" /></td></tr>
   <tr><th>初始发行量:</th><td><input class="input" datatype="n" type="text" name="num_of" value="{$info.num_of}" /> <span class="gray">仅用于剩余发行量百分比计算</span></td></tr>
   <tr><th>剩余发现量:</th><td><input class="input" datatype="n" type="text" name="num" value="{$info.num}" /> <span class="gray">库存基数值，剩余比例 </span><span class="fn-fb red percentage">0%</span></td></tr>
   <tr><th>额度大小(￥):</th><td><input class="input" datatype="npot" type="text" name="size" value="{$info.size}" /></td></tr>
   <tr class="discount{$info.types == 0 ?' fn-hide':''}"><th>单次折扣:</th><td><input class="input" datatype="npot" type="text" name="discount" value="{$info.discount}" /> 折</td></tr>
   <tr class="price{$info.types == 1 ?' fn-hide':''}"><th>单次减免(￥):</th><td><input class="input" datatype="npot" type="text" name="price" value="{$info.price}" /> 元</td></tr>
   <tr><th>满多少可用(￥):</th><td><input class="input" datatype="npot" type="text" name="howmuch" value="{$info.howmuch}" /></td></tr>
   <tr><th>图片样式</th><td><div url="{:url('system/passport.common/upload')}" class="selectid fn-cp img-review">{if $info.img}<img src="{$info.img}">{else /}<img src="__PUBLIC__/admin/review.png">{/if}</div></td></tr>
    <tr>
        <th></th>
        <td>
            <input type="submit" value="确定" class="button button-blue submit" />
            <input type="reset" value="重置" class="button button-blank"/>
        </td>
    </tr>
</table>
</div>
</form>
<script type="text/javascript">
Do('base','layer','form','date', function () {
    $('#form').isForm();
    var num_of = parseInt($("input[name='num_of']").val()),num = parseInt($("input[name='num']").val());
    var percentage = parseInt(num/num_of*100);
    if(!isNaN(percentage)){ $(".percentage").text(percentage+'%')}
    $(".selectid").win();
    $("#types").change(function(){
        var type = $(this).val();  
        if(type == 0){
            $('.discount').hide();
            $('.price').show();
        }else{
            $('.discount').show();
            $('.price').hide();
        }
    });
})
//添加图片
function setImg(show_src){
    $("#picture").val(show_src);
    $(".img-review").html('<img src="'+show_src+'">');  
}
function setState(store){
    $('#store_id').val(store.id);
}
</script>